﻿using Architecture.CrossCutting.Tracing.Models;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Architecture.CrossCutting.LoggingEntities.Mapping
{
    public class IISLogMap : EntityTypeConfiguration<IISLog>
    {
        public IISLogMap()
        {
            //Primary Key
            this.HasKey(l => l.RequestId);

            //FIXME : How handle this tow columns in only one property Date Time ?
            this.Ignore(l => l.RequestDate);

            //define properties
            this.Property(l => l.SiteName).HasColumnName("s-sitename");
            this.Property(l => l.ServerIp).HasColumnName("s-ip");
            this.Property(l => l.ClientMethod).HasColumnName("cs-method");
            this.Property(l => l.ClientUri).HasColumnName("cs-uri-stem");
            this.Property(l => l.ClientQuery).HasColumnName("cs-uri-query");
            this.Property(l => l.ServerPort).HasColumnName("s-port");
            this.Property(l => l.ClientUserName).HasColumnName("cs-username");
            this.Property(l => l.ClientIp).HasColumnName("c-ip");
            this.Property(l => l.ClientVersion).HasColumnName("cs-version");
            this.Property(l => l.ClientAgent).HasColumnName("cs-User-Agent");
            this.Property(l => l.ResponseStatus).HasColumnName("sc-status");
            this.Property(l => l.ResponseSubStatus).HasColumnName("sc-substatus");
            this.Property(l => l.ResponseWin32Status).HasColumnName("sc-win32-status");
            this.Property(l => l.ResponseSize).HasColumnName("sc-bytes");
            this.Property(l => l.RequestSize).HasColumnName("cs-bytes");
            this.Property(l => l.Duration).HasColumnName("time-taken");

            this.ToTable("IISLogs", "dbo");
        }

    }
}
